<script setup lang='ts'>
  import { onMounted, reactive } from 'vue';
  import { gamesApi } from '@/api/controller';
  import { Toastloading } from '@/utils/public';
  import { getPlayEndTime, getDateArray } from '@/utils'
  import Pagination from "@/components/Pagination/index.vue";
  const action = reactive({
    total:0,
    list:[] as any[],
    dateArr:getDateArray('ymdhis') as Array<string>
  })
  const listQuery = reactive({
    page:1,
    limit:20
  })
  const resetQuery = ()=>{
    action.dateArr = getDateArray('ymdhis') as Array<string>
    handleSerach()
  }
  const handleSerach = ()=>{
    listQuery.page = 1
    getList()
  }
  const getList = async()=> {
    const loading = Toastloading()
    const timeObi = getPlayEndTime(action.dateArr)
    const res = await gamesApi.angerbirdStatGameEvery({
      ...listQuery,
      date_st:timeObi.playTime,
      date_ed:timeObi.endTime
    })
    loading.close()
    const { list=[], total=0 } = res?.data || {}
    action.list = list
    action.total = total
  }
  onMounted(()=>{
    getList()
  })
</script>

<template>
  <div class="xm-content">
    <div class="labelBox">
      <div class="labelItem">
        <div class="label">时间：</div>
        <el-date-picker
          v-model="action.dateArr"
          type="datetimerange"
          format="YYYY-MM-DD HH:mm:ss"
          value-format="YYYY-MM-DD HH:mm:ss"
          range-separator="至"
          start-placeholder="开始时间"
          end-placeholder="结束时间"
        />
      </div>
      <div class="labelItem">
        <el-button type="primary" @click="handleSerach">查询</el-button>
        <el-button type="primary" @click="resetQuery">重置</el-button>
      </div>
    </div>
    <el-table
      class="xm-TableCenter"
      :data="action.list"
      border>
      <el-table-column min-width="120" prop="game_num" label="局数ID" />
      <el-table-column min-width="120" prop="stakeUserAll" label="参与人数" />
      <el-table-column min-width="120" prop="stakeNumAll" label="参与次数" />
      <el-table-column min-width="120" prop="stakeNum" label="成功次数" />
      <el-table-column min-width="130" prop="stakePriceAll" label="参与数(能量)" />
      <el-table-column min-width="130" prop="stakeDiamondAll" label="参与数(钻石)"/>
      <el-table-column min-width="130" prop="rewardPriceAll" label="兑换数(能量)" />
      <el-table-column min-width="130" prop="rewardDiamondAll" label="兑换数(钻石)" />
      <el-table-column min-width="130" prop="porfitPoolAll" label="平台费率(能量)" />
      <el-table-column min-width="130" prop="porfitDiamondAll" label="平台费率(钻石)" />
      <el-table-column min-width="130" prop="profitNum" label="利润数量(钻石)" />
      <el-table-column min-width="130" prop="profitRate" label="利润率" />
      <el-table-column min-width="130" prop="profitTotal" label="利润礼物池(能量)" />
      <el-table-column min-width="130" prop="trackPoolTotal" label="赔付礼物池(能量)" />
    </el-table>
    <Pagination v-show="action.total > 0" :total="action.total" v-model:page="listQuery.page"
      v-model:limit="listQuery.limit" @pagination="getList" />
  </div>
</template>
